<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/amazeui.min.css" />
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/hy.admin.css" />
	</head>

	<body>
		{include file='../Common/hy_header.html'}
		<div class="am-g">
			<div class="am-tabs am-margin" data-am-tabs="">
				<ul class="am-tabs-nav am-nav am-nav-tabs">
					<!-- <li class="am-active"><a hidefocus="true" href="#tab1">基本详情</a>
					</li>
					<li class="" ><a hidefocus="true" href="#tab3">SEO 选项</a>
					</li> -->
				</ul>

				<div class="am-tabs-bd am-form" style="touch-action: pan-y; -webkit-user-select: none; -webkit-user-drag: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);">

					<div class="am-tab-panel am-fade am-active am-in" id="tab1">
						
						<div class="am-g am-margin-top">
							<div class="am-u-sm-2 am-text-right">
								奖品名称
							</div>
							<div class="am-u-sm-4 am-u-end">
								<select style="width:230px;" name="prize_name" id="prize_name"  style="width:150px;height:35px;">   
									{foreach from=$prize_name item=na}
								    	<option value="{$na.id}" {if $na.id==$res.pid}selected = "selected"{/if}>{$na.prize_name}</option>   
								    {/foreach}   
								</select>
							</div>
						</div>

						<div class="am-g am-margin-top">
							<div class="am-u-sm-2 am-text-right">
								奖品数量
							</div>
							<div class="am-u-sm-4 am-u-end">
								<input type="text" style="width:230px;" id="nums" value="{$res.nums}" class="am-input-sm">
							</div>
						</div>
						
						<div class="am-g am-margin-top">
							<div class="am-u-sm-2 am-text-right">
								开始时间
							</div>
							<div class="am-u-sm-4 am-u-end">
								<input value="{$res.begintime}"  style="width:230px;" type="text" id="begintime" name="begintime" class="field am-form-field hy-js-search">
							</div>
						</div>
						
						<div class="am-g am-margin-top">
							<div class="am-u-sm-2 am-text-right">
								结束时间
							</div>
							<div class="am-u-sm-4 am-u-end">
								<input value="{$res.endtime}"  style="width:230px;" type="text" id="endtime" name="endtime" class="field am-form-field hy-js-search">
							</div>
						</div>
						
						<input type="hidden" id="shd" value="{$res.id}" placeholder="" >
						<div class="am-margin" style="margin-left:25%;">
							<button type="button" onclick="submit()" class="am-btn am-btn-primary am-btn-xs">提交保存</button>
						</div>

					
				</div>
				
			</div>
		</div>
		<div class="hy-footer">

		</div>
		{include file='../Common/hy_footer.html'}
		<script type="text/javascript" src="{$_C.hy_path}js/editor/kindeditor.js"></script>
		<script type="text/javascript" src="{$_C.hy_path}js/laydate/laydate.js"></script>
		<script type="text/javascript">
			$(function(){
				  
				  laydate({
				   elem: '#begintime',
				   istime:true,
				   format: 'YYYY-MM-DD hh:mm:ss',
				});
				  laydate({
				   elem: '#endtime',
				   istime:true,
				   format: 'YYYY-MM-DD hh:mm:ss',
				})	
			})
			
			function submit()
			{
				
				if($("#nums").val()=='')
				{
					showMsg('奖品个数不能为空',1);
					return;
				}
				if($("#begintime").val()=='')
				{
					showMsg('开始时间不能为空',1);
					return;
				}
				if($("#endtime").val()=='')
				{
					showMsg('结束时间不能为空',1);
					return;
				}
				
				$.ajax({
					type:"POST",
					url:"index.php?g=admin&m=car&a=set_rule",
					data:{
						id:$("#shd").val(),
						pid:$("#prize_name option:selected").val(),
						nums:$("#nums").val(),
						begintime:$("#begintime").val(),
						endtime:$("#endtime").val()
					},
					dataType:"json",
					success:function(data){
						if(data.error == 1){
							showMsg(data.content,1);
						}
						else{
							showMsg(data.content,0);
						}
					},
					error:function(){
						
					}
				});
			}
		</script>
	</body>

</html>